<?php if(!empty($resources)):?>
<ol>
<?php foreach($resources as $uri => $properties):?>
	<li>
		<?php
		if(isset($properties['dc:title'])) $prop = 'dc:title';
		 else if(isset($properties['rdfs:label'])) $prop =  'rdfs:label';
		 else $prop = false; 
		?>
		<h2 xml:lang="<?php echo $properties[$prop][0]['lang']?>">
			<a href="/Res/?uri=<?php echo urlencode($uri)?>"><?php echo (isset($properties[$prop]))? $properties[$prop][0]['value'] : $uri?></a>
			<span class="uri">(<?php echo $uri?>)</span>
		</h2>

	</li>
<?php endforeach?>
</ol>
<?php elseif(empty($resources) && isset($resources)):?>
	<p>
		There were no matching results - sorry.
	</p>
<?php endif?>


<form method="get" accept-charset="utf-8">
<fieldset>
	<legend>Template Query</legend>
			<textarea name="query" rows="20" cols="80">
<?php if(isset($_GET['query'])):?>
	<?php echo strip_tags($_GET['query'])?>
<?php else: ?>
{
  "prefixes" : {
    "foaf" : "http://xmlns.com/foaf/0.1/" ,
    "dc" : "http://purl.org/dc/elements/1.1/" 
   } ,

 "resources": { "?query" : {

    		"dc:title" : [  ] ,

  		} ,
	},
}
<?php endif?>
</textarea>
<label>Number of Results:
	<select name="limit">
		<option>10</option>
		<option>20</option>
		<option>50</option>
		<option>100</option>
		<option>200</option>
	</select>
</label>
<label>Format:
	<select name="format">
		<option>html</option>
		<option>rdf</option>
		<option>json</option>
		<option>jsonp</option>
	</select>
</label>
</fieldset>

		<p><input type="submit" value="Query &rarr;"></p>
</form>
